<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>店面自营产品类别管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		global.loginPassword = "${fns:getLoginPw()}";
		$(document).ready(function() {
			$("#contentTable tbody tr").click(function(){
				$("#contentTable tbody tr").removeClass("select_active");
				$(this).addClass("select_active");
			});
			$(".operateTD").click(function(){
				operateMenu(this.id);
			});
		});
		function operateMenu(id){
			var type = '${type}';
			item = $("#opreation-"+ id);
			if(item.length > 0) {
				$(".ui-icon-arrow-u").removeClass("ui-icon-arrow-u").addClass("ui-icon-arrow-d");
				item.remove();
				this.event.stopPropagation();
				return;
			}
			$("#"+id + " .ui-icon-arrow-d").removeClass("ui-icon-arrow-d").addClass("ui-icon-arrow-u");
			$(".opreationTR").removeClass("opreationTR");
			$(".opreation").remove();
			var html= "<tr id='opreation-" + id + "' class='opreation'><td colspan='6'>";
				html += '<a data-role="button" data-inline="true"  href="${ctx}/base/storeSelfProductCategory/form?id=' + id + '">修改产品分类</a>';
				html += '<a data-role="button" data-inline="true"  onclick="openDetail(' + id + ')">查看产品明细</a>';
				html += '</td></tr>';
			$("#tr-" + id).after(html);
			$("#tr-" + id).addClass("opreationTR");
			$("#contentTable").trigger("create");
			this.event.stopPropagation();
		}
		function openDetail(id){
			var url = "${ctx}/base/storeSelfProduct/list?category_id=" + id;
			window.location.href = url;
		}
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<div data-role="navbar">
	    <ul>
	        <li><a href="${ctx}/expert/productCategory/">系统产品</a></li>
	        <li><a href="${ctx}/base/storeSelfProductCategory/" class="ui-btn-active">店面自营产品</a></li>
	    </ul>
	</div>
	<div class="icon-buttons">
		<input type="button" class="leave-clean-session" data-inline="true" data-icon="back" data-iconpos="notext" value="返回"/>
	</div>
	<form:form id="searchForm" modelAttribute="storeSelfProductCategory" action="${ctx}/base/storeSelfProductCategory/" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input type="button" value="店面产品分类添加" data-inline="true" onclick="loginPasswordPopup('${ctx}/base/storeSelfProductCategory/form')">
		<label>按产品分类名称查询 ：&nbsp;&nbsp;</label>
		<input type="search" id="searchName" name="searchName" value="${searchName}"/>
		<input id="btnSubmit" type="submit" value="查询" data-inline="true"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead><tr><th>产品分类名称</th><th>描述</th><th>操作</th></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="storeSelfProductCategory">
			<tr id='tr-${storeSelfProductCategory.id}' >
				<td>${storeSelfProductCategory.name}</td>
				<td class="description">${storeSelfProductCategory.description}</td>
				<td class="operateTD" id="${storeSelfProductCategory.id}">
					<input type="button" data-inline="true" data-icon="arrow-d" data-iconpos="notext">
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
